/**
 * Wang Sen (C) <senwang@linux.vnet.ibm.com>
 * 2012.3.17
 */
#include <linux/module.h>
#include <linux/init.h>
#include <linux/list.h>

typedef struct {
	char *name;
	int id;
	struct list_head vm_list;
} VM, *VMP;

VM vm[] = {{.name = "vm1", .id = 0}, {.name = "vm2", .id = 1}, {.name = \
	"vm3", .id = 2}};

static int __init list_test_init(void)
{
	LIST_HEAD(vmlist);
	struct list_head *p = NULL;
	VMP ep = NULL;
	
	printk("------init\n");
	list_add(&vm[0].vm_list, &vmlist);
	list_add(&vm[1].vm_list, &vmlist);
	list_add(&vm[2].vm_list, &vmlist);
	list_for_each(p, &vmlist) {
		ep = list_entry(p, VM, vm_list);
		printk("name: %s, id: %d", ep->name, ep->id);
	}
	return 0;
}

static void __exit list_test_exit(void)
{
	printk("------exit\n");
}

module_init(list_test_init);
module_exit(list_test_exit);
